package cn.petplatform.petback.controller.petadopt;

//引入相关包
import cn.petplatform.annotations.LoginVerifyToken;
import cn.petplatform.annotations.PassToken;
import cn.petplatform.dto.ResponseDto;
import cn.petplatform.petback.pojo.Pet;
import cn.petplatform.petback.pojo.PetAdopt;
import cn.petplatform.petback.pojo.vo.AdoptInfoVo;
import cn.petplatform.petback.service.adoptpets.AdoptPetsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;

/**
 * @author LNL
 * @date 2021/5/17 16:34
 */
@RestController
@Api(tags = "宠物领养")
@RequestMapping("/petAdopt")
public class PetAdoptController {

    //自动注入
    @Autowired
    private AdoptPetsService adoptPetsService;

    //路径接收的注解
    @GetMapping("/adopts")
    //注解
    @ApiOperation(value = "获取所有的领养信息")
    @PassToken
    public ResponseDto getAdoptPets() {
        ResponseDto responseDto = adoptPetsService.getAdoptPets();
        return responseDto;
    }

    @GetMapping("/adopt/{id}")
    @ApiOperation("通过id获取个人领养情况")
    @PassToken
    public ResponseDto getAdoptPetsByPerson(@ApiParam("用户id") @PathVariable("id") String id) {
        ResponseDto responseDto = adoptPetsService.getAdoptPetsByPerson(id);
        return responseDto;
    }

    @GetMapping("/adoptsManage")
    //SpringBoot+   My ba tis
    //接口信息注解
    @ApiOperation(value = "获取所有的领养管理信息")
    //通过验证注解
    @PassToken
    public ResponseDto getAdoptManagePets() {
        ResponseDto responseDto = adoptPetsService.getAdoptManagePets();
        return responseDto;
    }
    @PostMapping("/care")
    @ApiOperation("异步增加关注数")
    @PassToken
    public ResponseDto addCareCount(@RequestBody Pet pet) {
        //控制器调用业务层的逻辑
        ResponseDto responseDto = adoptPetsService.addCareCount(pet);
        return responseDto;
    }

    @GetMapping("/adoptOne/{id}")
    @ApiOperation("通过领养id获取单条领养情况")
    @PassToken
    public ResponseDto getAdoptPetsByAdoptId(@ApiParam("领养id") @PathVariable("id") String id) {
        ResponseDto responseDto = adoptPetsService.getAdoptPetsByAdoptId(id);
        return responseDto;
    }

    @ApiOperation("删除领养信息")
    @PostMapping("/delete/{id}")
    @LoginVerifyToken
    public ResponseDto deleteAdoptPetById(@ApiParam("领养宠物id") @PathVariable("id") String id) {
        ResponseDto responseDto = adoptPetsService.deleteAdoptPetById(id);
        return responseDto;
    }

    @LoginVerifyToken
    @ApiOperation("新增领养信息")
    @PostMapping("/insert/{id}")
    public ResponseDto insertAdoptPetByPerson(@ApiParam("宠物id") @PathVariable("id") String id,
                                              HttpServletRequest request) {
        ResponseDto responseDto = adoptPetsService.insertAdoptPetByPerson(id,request);
        return responseDto;
    }
    @LoginVerifyToken
    @ApiOperation("审核领养信息")
    @PostMapping("/check/{id}")
    public ResponseDto checkAdopt(@ApiParam("领养信息id") @PathVariable("id") String id,
                                              HttpServletRequest request) {
        ResponseDto responseDto = adoptPetsService.checkAdopt(id,request);
        return responseDto;
    }






}
